﻿using LogException;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace LogException
{
    /// <summary>
    /// 应用程序错误处理类
    /// </summary>
    public class AppException
    {
        /// <summary>
        /// 应用程序域中异常处理函数：应用程序抛出异常
        /// </summary
        public static void DomainUnhandledException(object sender, UnhandledExceptionEventArgs args) 
        {
            Exception ex = (Exception)args.ExceptionObject;
            LogUtil.WriteLog_Error(sender.GetType(), ex);
            new ErrorForm(ex).Show();
        }

        /// <summary>
        /// 线程错误处理函数
        /// </summary>
        /// <param name="workerThreadException"></param>
        /// <param name="threadExceptionEventArgs"></param>
        public  static void UnhandledException(AppThreadException workerThreadException, System.Threading.ThreadExceptionEventArgs threadExceptionEventArgs)
        {
            Exception ex = threadExceptionEventArgs.Exception;
            LogUtil.WriteLog_Error(workerThreadException.GetType(), ex);
            //new ErrorForm(ex).Show();
        }
    }
}
